<template>
  <div id="video_app">
    <nav-header></nav-header>
    <div class="zh-video-config">
      <el-form ref="st_form" label-position="top">
        <el-form-item label="S-T分析配置">
          <el-radio-group v-model="st_form.status">
            <el-radio label="1">开启</el-radio>
            <el-radio label="2">关闭</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item>
          <el-button size="small" type="primary" @click.stop="changeST">保存</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="zh-video-config">
      <el-form ref="ai_form" label-position="top">
        <el-form-item label="AI分析配置">
          <el-radio-group v-model="ai_form.status">
            <el-radio label='1'>开启</el-radio>
            <el-radio label='2'>关闭</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item>
          <el-button size="small" type="primary" @click.stop="changeAI">保存</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      st_form: {
        type: 1,
        status: '',
      },
      ai_form: {
        type: 2,
        status: '',
      },
    }
  },

  created() {
    this.init();
  },

  methods: {
    init() {
      this.getST();
      this.getAI();
    },
    getST() {
      let success = (res => {
        this.st_form.status = res.data.st_show.toString();
      })
      this.$ajax.get('/api/video/video_app_show', { params: { type: this.st_form.type }, func: { success: success } })
    },

    getAI() {
      let success = (res => {
        this.ai_form.status = res.data.ai_show.toString();
      })
      this.$ajax.get('/api/video/video_app_show', { params: { type: this.ai_form.type }, func: { success: success } })
    },

    changeST() {
      let success = (res => {
        this.$message.success(res.msg);
        this.init();
        // this.$message.success(data.msg);
      })
      this.$ajax.put('/api/video/video_app_show', { type: 1, status: this.st_form.status}, {func: { success: success }} )
    },
    changeAI() {
      let success = (res => {
        console.log('aaa')
        this.$message.success(res.msg);
        this.init();
      })
      this.$ajax.put('/api/video/video_app_show',{ type: 2, status: this.ai_form.status}, {func: { success: success } })
    }
  }
}
</script>

<style lang="scss" scoped>
.zh-video-config {
  border-bottom: 1px solid #e6e6e6;
  margin-bottom: 20px;
}
</style>